package com.sc.web.gwt.client.presenter;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.sc.web.gwt.client.ClientFactory;
import com.sc.web.gwt.client.place.AgentWidgetPlace;
import com.sc.web.gwt.client.view.agentwidget.AgentWidgetView;

public class AgentActivity extends AbstractActivity implements AgentWidgetView.Presenter {
    // Used to obtain views, eventBus, placeController
    // Alternatively, could be injected via GIN
    private ClientFactory clientFactory;
    private AgentWidgetView agentWidgetView;

    public AgentActivity(AgentWidgetPlace place, ClientFactory clientFactory) {
        this.clientFactory = clientFactory;
    }

    public void goTo(Place place) {
        clientFactory.getPlaceController().goTo(place);
    }

    public void start(AcceptsOneWidget panel, EventBus eventBus) {
        agentWidgetView = clientFactory.getAgentWidgetView();
        agentWidgetView.setPresenter(this);
        panel.setWidget(agentWidgetView.asWidget());
    }
}
